package com.woniuxy.services.impl;

import com.woniuxy.daos.CompanyDao;
import com.woniuxy.entitys.Company;
import com.woniuxy.services.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    public CompanyDao companyDao;

    //查询所有用户（公司）信息
    @Override
    public List<Company> getAllCompanies() {
        return companyDao.getAllCompanies();
    }

    //根据主键查询公司信息
    @Override
    public Company selectByPrimaryKey(Integer com_id) {
        return companyDao.selectByPrimaryKey(com_id);
    }

    public Integer updateByPrimaryKey(Company company){
        int i = companyDao.updateByPrimaryKey(company);
        return i;
    }

    //新增用户
    @Override
    public Integer insertSelective(Company company) {
        return companyDao.insertSelective(company);
    }

    //更改用户状态
    @Override
    public Integer updStatus(String com_status, String com_id) {
        return companyDao.updStatus(com_status,com_id);
    }

    //查询功能
    @Override
    public List<Company> search(String com_name) {
        return companyDao.search(com_name);
    }

    //根据满意度分组查询公司数量
    @Override
    public List<Map<String, Integer>> getCountBySatisfy() {
        return companyDao.getCountBySatisfy();
    }

    //根据信用度分组查询公司数量
    @Override
    public List<Map<String, Integer>> getCountByCredit() {
        return companyDao.getCountByCredit();
    }

    //获取所有已流失客户信息
    @Override
    public List<Company> getAllLostCompanies() {
        return companyDao.getAllLostCompanies();
    }
}
